@echo off

REM usage: buildcurl.cmd BUIL_DIR BUILD_LOG [Release]

set TMP_BUILD_DIR=build
IF NOT "%1"=="" set TMP_BUILD_DIR=%1

set BUILD_LOG=build.log
IF NOT "%2"=="" set BUILD_LOG=%2

set CONF=Debug
IF NOT "%3"=="" set CONF=%3

set WORKDIR=%CD%\..
REM set EXTPACK_ROOT=%WORKDIR%\..\extpack

REM using swigwin for win32 in extpack
set SWIGPATH=%EXTPACK_ROOT%\swig\swigwin-2.0.4

REM using cmake for win32 in extpack
set CMAKEPATH=%EXTPACK_ROOT%\cmake\cmake-2.8.5-win32-x86

REM CMAKE binary path
set PATH=%PATH%;%CMAKEPATH%\bin


IF EXIST %TMP_BUILD_DIR% ( rd /S /Q %TMP_BUILD_DIR% )

mkdir %TMP_BUILD_DIR%
PUSHD %TMP_BUILD_DIR%
cmake -DCMAKE_INSTALL_PREFIX=%WORKDIR%\sdk -G "Visual Studio 9 2008" ..\curl-7.22.0
POPD

IF %CONF%==Debug GOTO Label_END
cmake --build %TMP_BUILD_DIR% --config "Release|Win32" -- /Out %BUILD_LOG%

:Label_END
IF %CONF%==Debug @pause


@echo "--- end build script ---"
